using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Categories;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
using BusinessObjects;
using BussinessObjects.BO_Actions.Categories;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Categories
    {

        public static string UpdateOrder(int category_id, int sort_display, DateTime modify_date, string modify_by)
        {
            try
            {
                BOCategories_Update_Order action = new BOCategories_Update_Order();
                usp_Categories_Update_Order entity = new usp_Categories_Update_Order();
                entity.CATEGORY_ID = category_id;
                entity.SORT_DISPLAY = sort_display;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOCategories_Select_All action = new BOCategories_Select_All();
                usp_Categories_Select_All entity = new usp_Categories_Select_All();
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable BeforeInsert(int category_id)
        {
            try
            {
                BOCategories_Before_Insert action = new BOCategories_Before_Insert();
                usp_Categories_Before_Insert entity = new usp_Categories_Before_Insert();
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOCategories_Select_Top action = new BOCategories_Select_Top();
                usp_Categories_Select_Top entity = new usp_Categories_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectParent(int category, int status)
        {
            try
            {
                BOCategories_Search_By_Parent action = new BOCategories_Search_By_Parent();
                usp_Categories_Search_By_Parent entity = new usp_Categories_Search_By_Parent();
                entity.CATEGORY_ID = category;
                //entity. = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int category_id)
        {
            try
            {
                BOCategories_Search action = new BOCategories_Search();
                usp_Categories_Search entity = new usp_Categories_Search();
                entity.CATEGORY_ID = category_id;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOCategories_Select_WithPaged action = new BOCategories_Select_WithPaged();
                usp_Categories_Select_WithPaged entity = new usp_Categories_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static DataTable SearchByParent(int category_id)
        {
            try
            {
                BOCategories_Search_By_Parent action = new BOCategories_Search_By_Parent();
                usp_Categories_Search_By_Parent entity = new usp_Categories_Search_By_Parent();
                entity.CATEGORY_ID = category_id;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(int parent_id, string short_category_name, string short_category_name_eng, string full_category_name, string full_category_name_eng, string thumb_icon, string short_category_description, string short_category_description_eng, string full_category_description, string full_category_description_eng, bool is_display_on_home_page, bool is_menu, int sort_display, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOCategories_Insert action = new BOCategories_Insert();
                usp_Categories_Insert entity = new usp_Categories_Insert();
                entity.PARENT_ID = parent_id;
                entity.SHORT_CATEGORY_NAME = short_category_name;
                entity.SHORT_CATEGORY_NAME_ENG = short_category_name_eng;
                entity.FULL_CATEGORY_NAME = full_category_name;
                entity.FULL_CATEGORY_NAME_ENG = full_category_name_eng;
                entity.THUMB_ICON = thumb_icon;
                entity.SHORT_CATEGORY_DESCRIPTION = short_category_description;
                entity.SHORT_CATEGORY_DESCRIPTION_ENG = short_category_description_eng;
                entity.FULL_CATEGORY_DESCRIPTION = full_category_description;
                entity.FULL_CATEGORY_DESCRIPTION_ENG = full_category_description_eng;
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.IS_MENU = is_menu;
                entity.SORT_DISPLAY = sort_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static string Update(int category_id, int parent_id, string short_category_name, string short_category_name_eng, string full_category_name, string full_category_name_eng, string thumb_icon, string short_category_description, string short_category_description_eng, string full_category_description, string full_category_description_eng, bool is_display_on_home_page, bool is_menu, int sort_display, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOCategories_Update action = new BOCategories_Update();
                usp_Categories_Update entity = new usp_Categories_Update();
                entity.CATEGORY_ID = category_id;
                entity.PARENT_ID = parent_id;
                entity.SHORT_CATEGORY_NAME = short_category_name;
                entity.SHORT_CATEGORY_NAME_ENG = short_category_name_eng;
                entity.FULL_CATEGORY_NAME = full_category_name;
                entity.FULL_CATEGORY_NAME_ENG = full_category_name_eng;
                entity.THUMB_ICON = thumb_icon;
                entity.SHORT_CATEGORY_DESCRIPTION = short_category_description;
                entity.SHORT_CATEGORY_DESCRIPTION_ENG = short_category_description_eng;
                entity.FULL_CATEGORY_DESCRIPTION = full_category_description;
                entity.FULL_CATEGORY_DESCRIPTION_ENG = full_category_description_eng;
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.IS_MENU = is_menu;
                entity.SORT_DISPLAY = sort_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static bool Delete(int category_id)
        {
            try
            {
                BOCategories_Delete action = new BOCategories_Delete();
                usp_Categories_Delete entity = new usp_Categories_Delete();
                entity.CATEGORY_ID = category_id;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Up(int category_id)
        {
            try
            {
                BOCategories_Up action = new BOCategories_Up();
                usp_Categories_Up entity = new usp_Categories_Up();
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Down(int category_id)
        {
            try
            {
                BOCategories_Down action = new BOCategories_Down();
                usp_Categories_Down entity = new usp_Categories_Down();
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int category_id)
        {
            try
            {
                BOCategories_Restore action = new BOCategories_Restore();
                usp_Categories_Restore entity = new usp_Categories_Restore();
                entity.CATEGORY_ID = category_id;

                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static DataTable GetMenu(int category_id)
        {
            try
            {
                BOCategories_Get_Menu action = new BOCategories_Get_Menu();
                usp_Categories_Get_Menu entity = new usp_Categories_Get_Menu();
                entity.CATEGORY_ID = category_id;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectSameParent(int category_id, int category_id_crr)
        {
            try
            {
                BOCategories_Same_Parent action = new BOCategories_Same_Parent();
                usp_Categories_Same_Parent entity = new usp_Categories_Same_Parent();
                entity.CATEGORY_ID = category_id;
                entity.CATEGORY_ID_CRR = category_id_crr;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Display(int category_id, bool isDisplay)
        {
            try
            {
                BOCategories_Display action = new BOCategories_Display();
                usp_Categories_Display entity = new usp_Categories_Display();
                entity.CATEGORY_ID = category_id;
                entity.IsDisplay = isDisplay;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable UpdateParent(int category_id, int category_id_cur)
        {
            try
            {
                BOCategories_Update_Parent action = new BOCategories_Update_Parent();
                usp_Categories_Update_Parent entity = new usp_Categories_Update_Parent();
                entity.CATEGORY_ID = category_id;
                entity.CATEGORY_ID_CUR = category_id_cur;

                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static string UpDown(int category_id, int sort_display)
        {
            try
            {
                BOCategories_UpDown action = new BOCategories_UpDown();
                usp_Categories_UpDown entity = new usp_Categories_UpDown();
                entity.CATEGORY_ID = category_id;
                entity.SORT_DISPLAY = sort_display;

                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Order(string strAdminModuleID, string delimiter, int start)
        {
            try
            {
                BOCategories_Order action = new BOCategories_Order();
                usp_Categories_Order entity = new usp_Categories_Order();
                entity.String = strAdminModuleID;
                entity.Delimiter = delimiter;
                entity.START = start;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

